{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 远程登录"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "生成配置文件"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`$ jupyter notebook --generate-config`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "此时，细心的你会发现根目录下已经生成了一个隐藏文件夹.jupyter"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img src=\"images/4.png\"/>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "修改配置文件jupyter_notebook_config.py"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "```bash\n",
    "c.NotebookApp.ip = '*'                                  # 允许从任意 IP 访问\n",
    "c.NotebookApp.port = 10097                              # 设置你的运行端口 (若端口已被占用，请与管理员联系)\n",
    "c.NotebookApp.open_browser = False                      # 运行 notebook 应用时不打开浏览器 (不会出现上文中的黄色提示)\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "然后cd到你的jupyter根目录，运行<br>\n",
    "$ jupyter notebook<br>\n",
    "注意：请回到你的jupyter根目录，否则网页链接稍有不同，但对于新手可能是个坑<br>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img src=\"images/5.png\"/>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "复制下方链接，粘贴在你的浏览器url栏中，将其中localhost换成你的服务器IP地址"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img src=\"images/6.png\"/>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "现在你的jupyter服务器已经搭好了,是不是很简单!<br>\n",
    "先别急，我们还有事要做。<br>\n",
    "现在我们的jupyter可以在任何一台联网设备上被任何人登录，这是很不安全的，下面我们给我们的jupyter设一个密码。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "进入ipython，我们使用哈希给自己生成一个密码"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img src=\"images/7.png\"/>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "继续修改配置文件jupyter_notebook_config.py"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "```bash\n",
    "c.NotebookApp.password = u'sha1:e5b780ddb086:9d236d103b0e52c8681ae04dc91fe0db18a525b1'\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "重启jupyter notebook，刷新浏览器。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img src=\"images/8.png\"/>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "输入密码，尽情享受你的jupyter空间吧！"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**One more thing**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "建议使用screen 命令在后台挂起jupyter进程，随开随用！<br>\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  },
  "nbTranslate": {
   "displayLangs": [
    "*"
   ],
   "hotkey": "alt-t",
   "langInMainMenu": true,
   "sourceLang": "en",
   "targetLang": "fr",
   "useGoogleTranslate": true
  },
  "toc": {
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": true,
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": "block",
   "toc_window_display": true
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
